#include "stdafx.h"
#include "utils.h"
using namespace std;

string toStdString(const std::wstring& s)
{
    unsigned int bufferSize = (unsigned int)s.length()+1;
    char* pBuffer = new char[bufferSize];
    memset(pBuffer, 0, bufferSize);
    WideCharToMultiByte(CP_ACP, 0, s.c_str(), (int)s.length(), pBuffer, bufferSize, NULL, NULL);
    std::string retVal = pBuffer;
    delete[] pBuffer;
    return retVal;
}

wstring toStdWString(const std::string& s)
{
    unsigned int bufferSize = (unsigned int)s.length()+1;
    WCHAR* pBuffer = new WCHAR[bufferSize];
    memset(pBuffer, 0, bufferSize*sizeof(WCHAR));
    MultiByteToWideChar(CP_ACP, 0, s.c_str(), (int)s.length(), pBuffer, bufferSize);
    std::wstring retVal = pBuffer;
    delete[] pBuffer;
    return retVal;
}